#!usr/bin/python
# -*- coding:utf-8 -*-
#Copyright 2024 pysail

"""
main.主程序参数说明
workpath当前项目的工作地址，默认为工程项目所在的文件路径
"""

import sys
import os
import time
if str(__file__).find("site-packages") < 0:
    sys.path.append(os.path.abspath(os.path.join(__file__,"../..")))

from base.pySett import PySett #引入全局设置
from base.pyLog import PyLog

def run():
    if len(sys.argv) == 1:
        sys.argv.append('welcome')
    workpath = None
    if '-workpath' in sys.argv:
        workpath = sys.argv[sys.argv.index('-workpath') + 1]
    else:
        workpath = os.path.dirname(__file__)
    sett = PySett(workpath=workpath, argv=sys.argv[1:])
    pack = "build.%s.py%s" % (sys.argv[1], sys.argv[1])
    if 'demo' in sys.argv:
        pack = 'demo.%s.py%s' % (sys.argv[2], sys.argv[2])
    try:
        clazz = sett.import_module(pack)
    except Exception as e:
        sett.log.err(e)

if __name__=="__main__":
    dt1 = time.time()
    run()
    dt2 = time.time()
    PyLog().loginit().info("Pysail任务本次运行时间: %.2f 秒!" % (dt2 - dt1))
